package com.platform.api;

import com.platform.annotation.LoginUser;
import com.platform.entity.ApiMessageEntity;
import com.platform.entity.UserVo;
import com.platform.service.ApiMessageService;
import com.platform.utils.Query;
import com.platform.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Controller
 *
 * @author zhurusen
 * @email 524227263@qq.com
 * @date 2018-07-01 18:59:09
 */
@RestController
@RequestMapping("/api/message")
public class ApiMessageController {
    @Autowired
    private ApiMessageService apiMessageService;

    /**
     * 查看列表
     */
    @RequestMapping("/list")
    public R list(@LoginUser UserVo loginUser, @RequestParam(value = "page", defaultValue = "1") Integer page) {
        Map params = new HashMap();
        params.put("page", page);
        params.put("limit", 10);
        params.put("sidx", "create_time");
        params.put("order", "desc");
        params.put("userId", loginUser.getId());
        Query query = new Query(params);
        List<ApiMessageEntity> apiMessageList = apiMessageService.queryList(query);
        return  R.ok(0, "获取成功", apiMessageList);
    }


}
